﻿using System;
using System.Windows.Input;
using DynamicModel;
using DynamicModelDemo.Wpf.Models;

namespace DynamicModelDemo.Wpf.ViewModels
{
    public class PersonDetailsViewModel : DynamicViewModel
    {
        //public ICommand SaveCommand { get; set; }
        //public ICommand CancelCommand { get; set; }

        public PersonDetailsViewModel()
        {
            Model = new DynamicModel.DynamicModel(new Person
                                         {
                                             Id = 1,
                                             FName = "Abc",
                                             LName = "Xyz",
                                             Dob = new DateTime(2011, 1, 1),
                                             Active = true,
                                             Salary = 12345

                                         }
            );

            //SaveCommand = new RelayCommand((object obj) => { }, (object obj) => Model.IsChanged);
            //CancelCommand = new RelayCommand((object obj) => { }, (object obj) => Model.IsChanged);
        }

        public DynamicModel.DynamicModel Model { get; set; }

        public bool CanExecuteCancel(DynamicModel.DynamicModel o)
        {
            return Model.IsDirty;
        }
        public void ExecuteCancel(DynamicModel.DynamicModel o)
        {
            ;
        }

        public bool CanExecuteSave(DynamicModel.DynamicModel o)
        {
            return Model.IsDirty;
        }

        public void ExecuteSave(DynamicModel.DynamicModel o)
        {
            ;
        }

    }
}
